<?php

class ParseXml
{
	private $elm;
	private $doc;
	private $xmlDoc;
	
	public function __construct($arr, $xml)
	{
		$this->xmlDoc = "public/xml/$xml";
		$this->elm    = $arr;		
		$this->doc    = new DomDocument;
		
		$this->doc->Load($this->xmlDoc);
		$this->create();
	}
	
	public function create()
	{
		$sites = $this->doc->getElementsByTagName("sites")->item(0);
		$site  = $this->doc->createElement("site");
		
		$sites->appendChild($site);

		foreach ($this->elm as $key => $val)
		{
			if(!$val)
			{
				continue;
			}
			
			$elm = $this->doc->createElement($key, $val);
			
			$site->appendChild($elm);			
		}
		
		$this->save();
	}
	
	public function save()
	{
		$this->doc->save($this->xmlDoc);
	}
}

?>